package com.zzty.demo.dao;

import com.zzty.demo.entity.Clazz;
import com.zzty.demo.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserMapper {
    @Select("select * from user where name=#{name}")
    User getUserByName(String name);

    @Update("update user set openId=#{openId} where name=#{name}")
    Integer updateOpenIdToUser(User user);

    @Select("select * from user where openId=#{openId}")
    User getUserByOpenId(String openId);

    @Select("select * from user")
    List<User> getAllUsers();

    @Select("select * from user where clazzid=#{id}")
    List<User> getUserByClazzid(Clazz clazz);

    @Select("select * from user where id=#{id}")
    User getUserById(Integer id);

    @Select("select * from user where openId=#{openId}")
    User getUser(User user);

    @Insert("insert into user(name,password,email,clazzId,type) values (#{name},#{password},#{email},#{clazzid},#{type})")
    Integer addUser(User user);

    @Select("select * from user where clazzid=#{clazzid} and id not in(#{id})")
    List<User> getUser2ById(User user);

}
